// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  env:'cloud1-7gb9s3y025614beb'
})

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  let user = event.user

  const db = cloud.database()
  const studentCollection = db.collection('pc_student')

  let student = studentCollection.doc(user._id)

  delete user._id

  let res = await student.update({
    data:{
      ...user
    }
  })
  return {
    res
  }
}